﻿using System;
using Gumini.JulaDB.Enums;
using Gumini.JulaDB.Provider;
using Gumini.JulaDB.Test.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Gumini.JulaDB.Test
{
    /// <summary>
    /// A set of tests involving specifying invalid data on the input. JulaDB should handle these cases gracefully and return an appropriate error code.
    /// </summary>
    [TestClass]
    public class InvalidSyntaxTest
    {
        private static JulaDbConnection _connection;
        private static PersonTestDataCreator _peopleData;

        [ClassInitialize]
        public static void InitializeDatabase(TestContext context)
        {
            _connection = TestUtils.CreateTestDatabase();
            _peopleData = new PersonTestDataCreator(_connection);
        }

        [ClassCleanup]
        public static void CleanupDatabase()
        {
            _connection.Close();
        }

        /// <summary>
        /// Attempting to execute a string of characters that does not make any sense.
        /// </summary>
        [TestMethod]
        public void RandomLetters()
        {
            _connection.ExecuteInvalidCommand(@"dg35w%^$RYGdfnvjisa sdFGe65etgrdfG4435y@%%&$", ErrorCode.SyntaxError);
        }

        /// <summary>
        /// Using an empty string as a command.
        /// </summary>
        [TestMethod]
        public void EmptyString()
        {
            _connection.ExecuteInvalidCommand(String.Empty, ErrorCode.SyntaxError);
        }

        /// <summary>
        /// Using null as a command.
        /// </summary>
        [TestMethod]
        public void Null()
        {
            _connection.ExecuteInvalidCommand(null, ErrorCode.CommandTextNotSet);
        }
    }
}
